import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *


import sys
from PyQt5.QtWidgets import QMainWindow, QApplication, QLabel
from PyQt5.QtGui import QPixmap
from PyQt5.QtCore import Qt


class Example(QMainWindow):

    def __init__(self):
        super().__init__()

        self.initUI()

    def initUI(self):

        # 创建状态栏
        self.statusbar = self.statusBar()

        # 创建左侧信息标签
        lbl_left = QLabel('Ready', self)
        self.statusbar.addPermanentWidget(lbl_left)

        # 创建右侧标签1
        lbl_right1 = QLabel(self)
        pixmap1 = QPixmap('icon1.png')  # 图片路径
        lbl_right1.setPixmap(pixmap1)
        lbl_right1.setCursor(Qt.PointingHandCursor)  # 设置鼠标手势为手形
        # 将鼠标单击事件绑定到自定义的 label1Clicked 槽函数
        lbl_right1.mousePressEvent = self.label1Clicked
        self.statusbar.addPermanentWidget(lbl_right1)

        # 创建右侧标签2
        lbl_right2 = QLabel(self)
        pixmap2 = QPixmap('icon2.png')  # 图片路径
        lbl_right2.setPixmap(pixmap2)
        lbl_right2.setCursor(Qt.PointingHandCursor)  # 设置鼠标手势为手形
        # 将鼠标单击事件绑定到自定义的 label2Clicked 槽函数
        lbl_right2.mousePressEvent = self.label2Clicked
        self.statusbar.addPermanentWidget(lbl_right2)

        self.setGeometry(300, 300, 350, 250)
        self.setWindowTitle('Statusbar')
        self.show()

    def label1Clicked(self, event):
        print("Hello from label1!")

    def label2Clicked(self, event):
        print("Hello from label2!")


if __name__ == '__main__':

    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())
